<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>myblog</title>
    <link href="/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        .navbar{
            margin-bottom:0;
        }
    </style>


</head>

<body>

<%- include('header') %>

<div class="container">
    <h3 >发表</h3>
    <form role="form"  >
        <div class="form-group">
            <label for="title">主题</label>
            <input type="text" class="form-control" id="title" name="title" placeholder="主题">
        </div>
        <div class="form-group">
            <label for="tags">标签</label>
            <input type="text" class="form-control" id="tags" name="tags" placeholder="标签">
        </div>
        <div class="form-group">
            <label for="content">正文</label>
            <textarea class="form-control" rows="3" id="content" name="content"></textarea>
        </div>

        <button type="button" id="btn_post" class="btn btn-default">发表</button>
    </form>
</div>


<!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery-1.11.3.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script type="text/javascript">
        $("#btn_post").click(function () {
            var title=$('#title').val();
            var tags=$('#tags').val();
            var content=$('#content').val();

            if(title==''){
                alert("请输入标题");
                $('#title').focus();
                return;
            }
            if(tags==''){
                alert("请输入标签");
                $('#tags').focus();
                return;
            }
            if(content==''){
                alert("请输入内容");
                $('#content').focus();
                return;
            }
            $.post('/frontend/blog/doposts',{
                title:title,
                tags:tags,
                content:content
            },function (result) {


                if(result=="-5"){
                    alert("服务器报错了");
                }else{
                    //alert("发表成功了");
                    window.location='/frontend/blog';
                }
            })
        })
</script>
</body>
</html>
